"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getRoot = getRoot;
exports.limit = limit;
var rootId = 'dzq-toast-root';

function getRoot(classPrefix) {
  var root = window[rootId] || document.getElementById(rootId);

  if (!root) {
    root = document.createElement('div');
    root.id = rootId;
    document.body.appendChild(root);
    window[rootId] = root;
  }

  return root;
}

var maxCountLimit = 1;
var listKey = 'dzq-toast-list-identification';

function limit(notice) {
  if (!window[listKey]) {
    window[listKey] = [];
  }

  if (window[listKey].length >= maxCountLimit) {
    try {
      window[listKey][0].hide();
      window[listKey].shift();
    } catch (_) {// hide failed
    }
  }

  window[listKey].push(notice);
}